<?php require_once('function.php');?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>gsUnity</title>

	<?php echo GetJsCss();?>
					
<script type="text/javascript">



	var aJaxURL			= "worker.action.php";					//server side folder url
	$(document).ready(function () {		

		
		GetMainDialog("dialog",1016,746);		
		GetLOgDialog("login-form",460,300); 	
		getPartTable();
		getWorkerTable();
		getInfoTable();

		setInterval(function(){checktimeuser()},60000);
		function checktimeuser(){
			var now = new Date();
			var h = now.getHours();
			var m = now.getMinutes();
			var s = now.getSeconds();	
			if (h==6 & m==0)
			{	
				$.ajax({
			        url: aJaxURL,
				    data: "act=all_work_end",
			        success: function(data) {
						if(typeof(data.error) != "undefined"){
							if(data.error != ""){
								alert(data.error);
							}else{
								alert(data.message);
								location.reload();
							}
						}
				    }
			    });
			}
			else{
				//$('body').html(h+":"+m+":"+s+"!= 7:6:00")
				}	
		} 

		$("#user").on("click", function() {
			$(".results").css({'display':'inline', 'zoom':'1'}); 
		});
		
		$("#active_catridgeBacode").focus();
		$('#ok_part').blur();
		$("#password").keyboard({

			 display: {
			  'bksp'   : '\u2190',
			  'enter'  : 'return',
			  'default': 'ABC',
			  'accept' : '\u21d3'
			 },

			 layout: 'custom',

			 customLayout: {

			  'default': [
			   '1 2 3',
			   '4 5 6',
			   '7 8 9',
			   '0 {bksp} {accept}'
			  ]
			 }

		});

	    $("#part_list_tbody").on("click", "#clickID", function () {        
	        var rID = $("#type", this).text();

	        if( $("#checkbox_"+rID).is(":checked") ){
	        	$("#checkbox_"+rID).prop('checked', false);
	        }else{
	        	$("#checkbox_"+rID).prop('checked', true);
	        } 
	             
	    });

	    $("#work-change").css( "height","40px" );
	    $("#log-in").css( "height","40px" );
	    $("#log-out").css( "height","40px" );
	    $("#ok_part").css( "height","40px" );
	    $("#go-timeout").css( "height","40px" );
	    $("#back-timeout").css( "height","40px" );
	    

	});
	
	$(document).on("click", ".button", function (event) {
		$("#"+$("#active").val()).removeClass("hver");
		$("#active").val(this.value);
		$("#"+this.value).addClass("hver");
		GetNotify1("დაასკანერეთ კატრიჯი!");
		event.preventDefault();					//Clear Dialog Default <b>keypress<b> Event

	});	
    
	$(document).on("keydown", "#barcode_input", function (event) {
		if (event.keyCode == $.ui.keyCode.ENTER){
			$("#active_catridgeBacode").val( $("#barcode_input").val() );
			$("#barcode_input").val("");
			getInfoTable();
			event.preventDefault();					//Clear Dialog Default <b>keypress<b> Event
        }
	});
	
	$(document).on("click", "li", function (event) {
		$("#user").val( $(this).html() );
		$(".results").css({'display':'none', 'zoom':'1'});	
		event.preventDefault();					//Clear Dialog Default <b>keypress<b> Event
	});
	
	$(document).on("click", "#ok_part", function (){
		SavePart();
		$("#active_catridgeBacode").val("");
		$(".button").removeClass("hver");
		$("#active").val("");
		
		getPartTable();
		getInfoTable();
		getHistoryTable();
	});
				
</script>
</head>
<body style="background: #E2F0FD url(../media/images/bg.png);" onselectstart='return false;'>
		
<div id="dialog" title="სამუშაო გვერდი" style="padding: 2px 2px 0px 10px !important; ">
	<table id="main-table"  border=0>
		<tr>
			<td rowspan="2">					
				<fieldset style="width: 185px; height: 620px;" >
				<legend><span>ამჟამად მუშაობენ </span></legend>
					<table id="worker_list" style="width: 175px;border-collapse:collapse;" >
						<tbody id="worker_list_tbody">								
						</tbody>
					</table>
				</fieldset>								
			</td>
			<td rowspan="2" >					

				<fieldset style="height: 620px; width: 310px;" >
			    	<legend>სამუშაო მხარე</legend>	    	
					<table class="tableClass" id="part_list"  style="width: auto;"  cellspacing='0' style=" vertical-align: baseline;"> <!-- cellspacing='0' is important, must stay -->
						<thead>
							<tr class="trClass">
								<th class="thClass" style="width: 200px;">ტიპი</th>
								<th class="thClass">#</th>
							</tr>
						</thead>
						<tbody id="part_list_tbody">								
						</tbody>
					</table>
					<div class="ui-dialog-buttonset" style="float:right; padding-right:10px;">
					<button type="button" id="ok_part" style="outline:none;"class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only">
						<span class="ui-button-text">შეცვლა</span>
					</button>
					</div>
					<div>
						<input type="text" style="opacity:0;filter:alpha(opacity=0); width: 0px; display: inline; padding: 0px;" id="barcode_input" value=""/>
					</div>
				</fieldset>							
			</td>
			
			<td>
								
				<fieldset style="width: 450px; height: 150px; vertical-align: middle; " >
					<legend><span>ინფორმაცია კატრიჯზე</span></legend>
					
					<table id="info_list"  style="float: left; font-family: BPG arial; font-weight: normal;"  class="dialog-form-table" cellspacing='8'>
						<tbody id="info_list_tbody">								
						</tbody>
					</table>
				
											
				</fieldset>								
			</td>																	
		</tr>
		<tr>
			<td>					
				<fieldset style="height: 454px; width: 450px;" >
				<legend><span>ისტორია</span></legend>
					<table class="tableClass" id="history_list"  style="width: auto;"  cellspacing='0' style=" vertical-align: baseline;"> <!-- cellspacing='0' is important, must stay -->
						<thead>
							<tr class="trClass">
								<th class="thClass" style="width: 200px;">ტიპი</th>
								<th class="thClass" style="width: 30px;">სულ</th>
								<th class="thClass" style="width: 50px;">არ გამოცვლილა</th>
								<th class="thClass" style="width: 50px;">ბოლო გამოცვლა</th>
							</tr>
						</thead>
						<tbody id="history_list_tbody">								
						</tbody>
					</table>
				</fieldset>								
			</td>	
		</tr>				
	</table>								
</div>

<div id="login-form" title="სისტემაში შესვლა" >
		<fieldset>
			<legend>ძირითადი ინფორმაცია</legend>
			<table width="80%" class="dialog-form-table" cellpadding="10px" >
				<tr	>
					<th style="float: left">
						<label for="user">მომხმარებელი</label>
					</th>
					<th>
						<div id="results_list" class="select_join"></div>
					</th>													
				</tr>
				<tr class="type"	>
					<th style="float: left">
						<label for="type">ტიპი</label>
					</th>
					<th>
						<div id="work_type" class="select_join"></div>
					</th>													
				</tr>
				<tr >				
					<th style="float: left">
						<label for="password">პაროლი&emsp;&emsp;&emsp;&nbsp;</label>
					</th>
					<th>
						<input id="password" class="user_input" type="password" autocomplete="off"/>
      				</th>																										

				</tr>									
			</table>
		</fieldset>
		<input type="text" id="hidden_action" style="visibility: hidden;" value="0"/>
</div>

<div >
	<input type="hidden" id="active" value=""/>	
</div>
<div >
	<input type="hidden" id="active_catridgeBacode" value=""/>	
</div>
</body>
</html>